	//팀목록
	function clsClubRoundAssign_Team(){
		this.listData = null;
		this._HTMLDom = null;
		this._init();	
	}
	
	clsClubRoundAssign_Team.prototype = {
		_init: function(){
			var $layer = $("section#club_round_assign>section div.club_assign_search");
			this._HTMLDom = {
				"$layer": $layer				
			}
			$layer.find("select").empty();
		}
		, setList: function(thisData){
			this.listData = thisData;
			this.display();
		}		
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			var $element = this._HTMLDom["$element"];
			var thisClass = this;
			
			$layer.find("select").empty();
			
			for(var i=0;i<this.listData.length;++i){				
				$layer.find("select").append("<option>"+ this.listData[i]["팀명"] +"</option>");
			}
		}
		, getValue: function(){
			var $layer = this._HTMLDom["$layer"];
			var n = $layer.find("option").index($layer.find("option:selected"));
			return this.listData[n]["팀키"];
		}
		, setValue: function(n){
			var $layer = this._HTMLDom["$layer"];			
			$layer.find("option").eq(n-1).prop("selected",true);			
			$layer.find("select").selectmenu("refresh");
		}
		, $getSelect: function(){
			return this._HTMLDom["$layer"].find("select");	
		}
	}
	
	//참여자목록
	function clsClubRoundAssign_Acc(){
		this.listData = null;
		this.compareData = null
		this._HTMLDom = null;
		this._init();	
	}
	
	clsClubRoundAssign_Acc.prototype = {
		_init: function(){
			var $layer = $("section#club_round_assign>section div.person_take:eq(0)");
			var $btns = $("section#club_round_assign>section div.updown_bt");
			this._HTMLDom = {
				"$layer": $layer
				, "$element": $layer.find("ul>li:first")
				, "$btns": $btns
			}
			$layer.find(">ul").empty();
			$layer.find("h3 span").html("0명");
		}
		, setList: function(thisData){
			this.listData = thisData;			
			this.compareData = _util.objectCopy(thisData);
			this.display();
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			var $element = this._HTMLDom["$element"];
			var thisClass = this;
			
			$layer.find(">ul").empty();
			
			for(var i=0;i<this.listData.length;++i){
				$layer.find(">ul").append($element.clone(true));
			}
			
			$layer.find(">ul>li").each(function(n){
				$(this).find("a img").attr("src", _util.getDefaultProfileImage(thisClass.listData[n]["이미지"]));
				$(this).find("h5").html(thisClass.listData[n]["닉네임"]);
				if(thisClass.listData[n]["성별"] == "M") {
					$(this).find("ul.per_info li:eq(0) span").attr("class", "sex_m").html("남");
				}else {
					$(this).find("ul.per_info li:eq(0) span").attr("class", "sex_w").html("여");
				}
				$(this).find("ul li:eq(1)").html(_util.getLocale(thisClass.listData[n]["지역"]));
				$(this).find("ul li:eq(2)").html(thisClass.listData[n]["나이대"] + "대");;
				$(this).find("ul li:eq(3)").html("핸디&nbsp;:&nbsp;" + thisClass.listData[n]["핸디"]);
				$(this).find("ul li:eq(4)").html("평균타수&nbsp;:&nbsp;" + thisClass.listData[n]["평타"]);
				$(this).find("label, input").remove();
				$(this).find("ul").after("<label><input type='checkbox' /></label>");
				$(this).find("input:checkbox").checkboxradio();
			}).css("cursor", "pointer");
		}
		, push: function(oneData){
			this.listData.push(oneData);
			this.display();
		}
		, splice: function(n){
			this.listData.splice(n,1);	
			this.display();
		}
		, $getChceckbox: function(){
			return this._HTMLDom["$layer"].find("input:checkbox");	
		}
		, $getBtnAssignCancel: function(){
			return this._HTMLDom["$btns"].find("div div button:eq(0)")	
		}
		, $getBtnAssignConfirm: function(){
			return this._HTMLDom["$btns"].find("div div button:eq(1)")	
		}
		, $getLayer: function(){
			return this._HTMLDom["$layer"].find(">ul");
		}	
	}
	
	//신청자목록
	function clsClubRoundAssign_Wait(){
		this.listData = null;
		this._HTMLDom = null;
		this._init();	
	}
	
	clsClubRoundAssign_Wait.prototype = {
		_init: function(){
			var $layer = $("section#club_round_assign>section div.person_take:eq(1)");
			this._HTMLDom = {
				"$layer": $layer
				, "$element": $layer.find(">ul>li:first")
			}
			$layer.find(">ul").empty();
			$layer.find("h3 span").html("<mark>0명</mark>&nbsp;/&nbsp;0명");
		}
		, setList: function(thisData){
			this.listData = thisData;
			this.display();
		}		
		, display: clsClubRoundAssign_Acc.prototype.display
		, push: clsClubRoundAssign_Acc.prototype.push
		, splice: clsClubRoundAssign_Acc.prototype.splice
		, $getChceckbox: clsClubRoundAssign_Acc.prototype.$getChceckbox
		, $getBtnAssignCancel: clsClubRoundAssign_Acc.prototype.$getBtnAssignCancel
		, $getBtnAssignConfirm: clsClubRoundAssign_Acc.prototype.$getBtnAssignConfirm
		, $getLayer: clsClubRoundAssign_Acc.prototype.$getLayer
	}
	//데이터연동		
	function clsComm_ClubRoundAssign(){		
		this.clubRoundAssignUserList=null;		
		
		this._init();
	}	
	clsComm_ClubRoundAssign.prototype = {
		_init: function(){
			this.clubRoundAssignUsertRequest = {
				 "동호회키":null
				, "라운드키": null
				, "팀키": null				
			}
		}
//------------------------ 라운드신청자목록------------------------//		
		, getClubRoundAssignUserList: function(){			
			var thisClass = this;
			
			var szClubSeq = this.clubRoundAssignUsertRequest["동호회키"];
			var szRoundSeq = this.clubRoundAssignUsertRequest["라운드키"]
			var szTeamSeq = this.clubRoundAssignUsertRequest["팀키"]
			
			var objJson = new MJson();
        	var cm = new ConnectionManager();
			
			objJson.putClient("userid", _util.getLogin("아이디"));
        	objJson.putPub("sid", "CL001");
        	objJson.putPub("servicename","prepareAssignment");   
        					
        	objJson.putParameter("clubSeq", szClubSeq);
        	objJson.putParameter("roundSeq", szRoundSeq);
        	objJson.putParameter("teamSeq", szTeamSeq);
			
			cm.requestGet(objJson.getJsonString(), function(ret){
				
				thisClass.clubRoundReplyList = [];
				
				var items = ret["msp"]["contents"]["items"];
			
				if(items){
			
					var user = [];
					var assigned = [];
					var team = [];
					
					//팀목록
					var teamList = items["roundTeamInfoList"];
					if(teamList[0]){
						
						if(!teamList[0]["items"].length){
							teamList[0]["items"] = new Array(teamList[0]["items"]);	
						}	
						
						for(var k=0;k<teamList[0]["items"].length;++k){							
							team.push({
								"라운드키":_util.nvl(teamList[0]["items"][k]["roundSeq"])
								, "팀키": _util.nvl(teamList[0]["items"][k]["teamSeq"])
								, "팀명": _util.nvl(teamList[0]["items"][k]["teamName"])
								, "배정회원수": _util.nvl(teamList[0]["items"][k]["assignedMemberCnt"])
							});
						}
					}
					
					//요청대기자
					var waitList = items["roundRequestUserList"];
					if(waitList[0]){
						
						if(!waitList[0]["items"].length){
							waitList[0]["items"] = new Array(waitList[0]["items"]);	
						}	
						
						for(var k=0;k<waitList[0]["items"].length;++k){							
							user.push({
								"팀키": ""
								, "아이디": _util.nvl(waitList[0]["items"][k]["userMaster"]["userId"])
								, "이미지": _util.nvl(waitList[0]["items"][k]["userMaster"]["path"]) + _util.nvl(waitList[0]["items"][k]["userMaster"]["saveFileName"])
								, "닉네임": _util.nvl(waitList[0]["items"][k]["userMaster"]["nickname"])
								, "성별": _util.nvl(waitList[0]["items"][k]["userMaster"]["sex"])
								, "핸디":_util.nvl(waitList[0]["items"][k]["userMaster"]["handi"])
								, "평타": _util.nvl(waitList[0]["items"][k]["userMaster"]["average"])
								, "지역": _util.nvl(waitList[0]["items"][k]["userMaster"]["region"])
								, "나이대": _util.nvl(waitList[0]["items"][k]["userMaster"]["age"])
							});
						}
					}
					
					//라운드확정자
					var accList = items["roundTeamInfo"];
					if(accList){						
						for(var i=1;i<=4;++i){
							var str = "assignedUser" + i + "Info";							
							if(accList[str]){						
								assigned.push({
									"팀키": _util.nvl(waitList["teamSeq"])
									, "아이디": _util.nvl(accList[str]["userId"])
									, "이미지": _util.nvl(accList[str]["path"]) + _util.nvl(accList[str]["saveFileName"])
									, "닉네임": _util.nvl(accList[str]["nickname"])
									, "성별": _util.nvl(accList[str]["sex"])
									, "핸디":_util.nvl(accList[str]["handi"])
									, "평타": _util.nvl(accList[str]["average"])
									, "지역": _util.nvl(accList[str]["region"])
									, "나이대": _util.nvl(accList[str]["age"])
								});
							}		
						}
					}
					
						
					//동호회목록
					thisClass.clubRoundAssignUserList = {
						"동호회키": _util.nvl(items["clubSeq"])
						, "라운드키": _util.nvl(items["roundSeq"])
						, "신청자": user
						, "배정자": assigned
						, "팀목록": team					
					};		
				}
				
				$(thisClass).trigger("evtFinishClubRoundAssignUserList");
			}, function($err) {
				alert("evtFinishClubRoundAssignUserList->"+$err);
			});	
		}
		, getClubRoundAssignUserData: function(){		
			return this.clubRoundAssignUserList;
		}
		, setClubRoundAssignUserListRequest: function(key, val){
			this.clubRoundAssignUsertRequest[key] = val;
		}
		, getClubRoundAssignUserListRequest: function(key){
			return this.clubRoundAssignUsertRequest[key];
		}	
//------------------------ 라운드신청자목록------------------------//					
//------------------------ 댓글삭제------------------------//			
		, InsertAssign: function(arg){
			var thisClass = this;
			
			var szClubSeq = arg["동호회키"];
			var szRoundSeq = arg["라운드키"];
			var szTeamSeq = arg["저장팀키"];
			var szUser1 = arg["용자1"];
			var szUser2 = arg["용자2"];
			var szUser3 = arg["용자3"];
			var szUser4 = arg["용자4"];
			
			var objJson = new MJson();
        	var cm = new ConnectionManager();
			
			objJson.putClient("userid", _util.getLogin("아이디"));
        	objJson.putPub("sid", "CL001");
        	objJson.putPub("servicename","assignUser");   
        					
        	objJson.putParameter("clubSeq", szClubSeq);
        	objJson.putParameter("roundSeq", szRoundSeq);
        	objJson.putParameter("teamSeq", szTeamSeq);
        	objJson.putParameter("assignedUser1", szUser1);
        	objJson.putParameter("assignedUser2", szUser2);
        	objJson.putParameter("assignedUser3", szUser3);
        	objJson.putParameter("assignedUser4", szUser4);
        	
			cm.requestGet(objJson.getJsonString(), function(ret){
				
				var resData = {
					"응답코드": (ret["msp"]["contents"]["serviceResult"] == "00000"?true:false)
					, "메세지": _util.getResultMsg(ret)
				}
				
				$(thisClass).trigger("evtFinishClubRoundAssignSubmit", [resData]);
			}, function($err) {
				alert("evtFinishClubRoundAssignSubmit->"+$err);
			});
		}		
//------------------------ 댓글삭제------------------------//			
	}
	
	//컨트롤파일
	function ClubRoundAssign(){				
		this.objComm = null;
		this.club_seq = null;	
		this.round_seq = null;
		this.team_seq = null;
		
		this.club_info = null;		
		this.objClubRoundAssign_Team = null;
		this.objClubRoundAssign_Wait = null;
		this.objClubRoundAssign_Acc = null;
	};
	
	ClubRoundAssign.prototype = {
	    onPageShow : function() {	    
	    	$("a").attr("href", "").attr("data-rel", "");      
	    	this._init();	    
	    }
	    , _beforeStart: function(){
	    	var 	thisClass = this;
	    	
	    	this._permitStart = {
				"동호회정보": false	
			}
			
	  		// 서버 메시지맵
			$.ajax({
				url: "../js/src/club/club_inc.js"
				, type: "get"
				, dataType: "script"
				, async: false
				, success: function(ret, sta){
					//alert("success!!");					
				}
				, error:function(e){
					alert("error=" + e);
				}	
			});
			
			_cb.getClubInfoData({
				"콜백": function(ret, l){
					thisClass._permitStart["동호회정보"] = true;	
				}
			});
			
			_util.executeThread(function(){
				for(key in thisClass._permitStart){		
					if(!thisClass._permitStart[key]) return false;
				}
				return (true);
			}, function(){			
				thisClass._start();
			});
	    }
	    , _init: function(){	    	    	
	    		    	
	    	this.objComm = new clsComm_ClubRoundAssign();
			this.objClubRoundAssign_Team = new clsClubRoundAssign_Team();
			this.objClubRoundAssign_Wait = new clsClubRoundAssign_Wait();
			this.objClubRoundAssign_Acc = new clsClubRoundAssign_Acc();
			
	      this.getParam();
	      
	      this._beforeStart();
	    	
	    	this._role();
	       
	      	this._bind();	 
	      	this._eventFinish();     	
	    }
	    , _start: function(){	    	
	    	//동호회기본정보
	    	this.club_info = _cb.getClubInfo();
	    	
	    	//신청자목록
	    	this.spinStart();
			this.objComm.setClubRoundAssignUserListRequest("동호회키", this.club_seq);
			this.objComm.setClubRoundAssignUserListRequest("라운드키", this.round_seq);
			this.objComm.setClubRoundAssignUserListRequest("팀키", this.team_seq);
			this.objComm.getClubRoundAssignUserList();
	    }
	    , _eventFinish: function(){
	    	var thisClass = this;
	    	
	    	//배정목록 조회 완료 이벤트(신청자,배정자,팀목록)
			$(this.objComm).bind("evtFinishClubRoundAssignUserList",function(event){
				var thisData= thisClass.objComm.getClubRoundAssignUserData();
				
				thisClass.objClubRoundAssign_Team.setList(thisData["팀목록"]);
				thisClass.objClubRoundAssign_Wait.setList(thisData["신청자"]);
				thisClass.objClubRoundAssign_Acc.setList(thisData["배정자"]);						
				thisClass.objClubRoundAssign_Team.setValue(thisClass.team_seq);
				thisClass.spinEnd();				
			});
			
			//배정하기 완료 이벤트
			$(this.objComm).bind("evtFinishClubRoundAssignSubmit",function(event, resData){
				alert(resData["메세지"]);		
				if(resData["응답코드"]){			
					thisClass.objComm.setClubRoundAssignUserListRequest("팀키", resData["조회팀키"]);	
					thisClass.objComm.getClubRoundAssignUserList();
				}
			});
	    }
		 , _bind: function(){
		 	var thisClass = this;
		 	
		 	//팀(셀렉트박스) 변경 이벤트
			this.objClubRoundAssign_Team.$getSelect().change(function(event){				
				var tmp = thisClass.team_seq;
				thisClass.team_seq = thisClass.objClubRoundAssign_Team.getValue();
				
				if(thisClass.isCompare()) {
					thisClass.objComm.setClubRoundAssignUserListRequest("팀키", thisClass.team_seq);					
					thisClass.objComm.getClubRoundAssignUserList();
				}else {
					if(confirm("변경된 정보를 저장하시겠습니까?")){				
						var submitData = thisClass.getSumbitData();
						submitData["저장팀키"] = tmp;
						thisClass.objComm.InsertAssign(submitData);
					}else {
						thisClass.objComm.setClubRoundAssignUserListRequest("팀키", thisClass.team_seq);
						thisClass.objComm.getClubRoundAssignUserList();
					}
				}				
			});
			
			//체크박스 넓게
			this.objClubRoundAssign_Wait.$getLayer().on("click", "li", function(event){
				var e = arguments[0] || event;
				var tName = e.target.tagName.toUpperCase();				
				if(tName == "SPAN" && $(e.target).hasClass("ui-icon")) return;
				
				var n = thisClass.objClubRoundAssign_Wait.$getLayer().find(">li").index($(this));
				
				var ck = thisClass.objClubRoundAssign_Wait.$getChceckbox();
				
				if(n==-1) return;
				
				ck.eq(n).prop("checked", !ck.eq(n).prop("checked")).checkboxradio("refresh");
			});
			
			//체크박스 넓게
			this.objClubRoundAssign_Acc.$getLayer().on("click", "li", function(event){
				var e = arguments[0] || event;
				var tName = e.target.tagName.toUpperCase();				
				if(tName == "SPAN" && $(e.target).hasClass("ui-icon")) return;
				
				var n = thisClass.objClubRoundAssign_Acc.$getLayer().find(">li").index($(this));
				
				var ck = thisClass.objClubRoundAssign_Acc.$getChceckbox();
				
				if(n==-1) return;
				
				ck.eq(n).prop("checked", !ck.eq(n).prop("checked")).checkboxradio("refresh");
			});
			
			//배정확정(->) 버튼 이벤트
			this.objClubRoundAssign_Acc.$getBtnAssignConfirm().click(function(event){
				 
				 var $checkbox = thisClass.objClubRoundAssign_Wait.$getChceckbox();
				 var $checked = thisClass.objClubRoundAssign_Wait.$getChceckbox().filter(":checked");
				 
				 var assignCnt = thisClass.objClubRoundAssign_Acc.listData.length;
				 
				 if($checked.length+assignCnt>4) {
				 	alert("선택된 인원이 최대인원(4명)이 초과되는 범위입니다. 다시 확인하십시요.");	
				 	return;
				}
				 
				 //반복문으로 인해 인덱스번호가 안맞는 경우가 있어 반대로 돌린다.
				 for(var i=$checked.length-1;i>=0;--i){
				 	var idx = $checkbox.index($checked[i]);
				 	thisClass.objClubRoundAssign_Acc.push(thisClass.objClubRoundAssign_Wait.listData[idx]);
				 	thisClass.objClubRoundAssign_Wait.splice(idx);
				}
			});			
			
			//배정취소(<-) 버튼 이벤트
			this.objClubRoundAssign_Acc.$getBtnAssignCancel().click(function(event){
				
				var $checkbox = thisClass.objClubRoundAssign_Acc.$getChceckbox();
				var $checked = thisClass.objClubRoundAssign_Acc.$getChceckbox().filter(":checked");
				 
				 //반복문으로 인해 인덱스번호가 안맞는 경우가 있어 반대로 돌린다.
				 for(var i=$checked.length-1;i>=0;--i){
				 	var idx = $checkbox.index($checked[i]);
				 	thisClass.objClubRoundAssign_Wait.push(thisClass.objClubRoundAssign_Acc.listData[idx]);
				 	thisClass.objClubRoundAssign_Acc.splice(idx);
				}
			});
			
			//확인
			$("section#club_round_assign>section div.btn_area07 div div a:eq(0)").click(function(event){
				event.preventDefault();
		 		
		 		if(thisClass.isCompare()) {
					alert("변경된 정보가 없습니다.");	
					return;
				}
				
				var submitData = thisClass.getSumbitData();
				thisClass.spinStart();
				thisClass.objComm.InsertAssign(submitData);
			});
			
			//취소
			$("section#club_round_assign>section div.btn_area07 div div a:eq(1)").click(function(event){
				event.preventDefault();
			 	_gf.CLUB_DATA = {
			 		"동호회키": thisClass.club_seq
			 		, "라운드키": thisClass.round_seq	
			 	}
			 	$.mobile.changePage("club_assign_view.html","slide",true);
			});
			
		 	//메뉴
		 	$("section#club_round_assign nav ul li a:eq(0)").click(function(event){
		 		event.preventDefault();
		 		thisClass.goNavi();
		 	});
		 	
		 	//알림
		 	$("section#club_round_assign nav ul li:eq(1)").click(function(event){
		 		event.preventDefault();
		 		$.mobile.changePage("../inc/info_booking.html","slide",true);	
		 	});
		 	
		 	//이전
		 	$("section#club_round_assign header div.top_title_B div.top_left a.btn10").click(function(event){
		 		event.preventDefault();
		 		_gf.CLUB_DATA = {
					"동호회키": thisClass.club_seq	
					, "라운드키": thisClass.round_seq
				}
		 		$.mobile.changePage("club_round_view.html","slide",true);	
		 	});
		 }
		 , getParam: function(){
	    	this.club_seq = _gf.CLUB_DATA["동호회키"];	    	    	
	    	this.round_seq = _gf.CLUB_DATA["라운드키"];
	    	this.team_seq = _util.nvl(_gf.CLUB_DATA["팀키"],1);
	    }
	    , _role: function(){
	    		
	   }
		, goNavi: function(){			
			$.mobile.changePage("../inc/navi.html","slide",true);
		}
		, goLogin: function(){
			_gf.LOGIN_DATA.loginAfterUrl = "../club/club_round_assign.html";
			$.mobile.changePage("../member/login.html","slide",true); 
		}
	    , spinStart: function(){		
			$.mobile.showPageLoadingMsg();			
		}
		, spinEnd: function(){			
	 		$.mobile.hidePageLoadingMsg();				
		}
		//저장데이터 생성
		, getSumbitData: function(){
			var szUser1 = null;
			var szUser2 = null;
			var szUser3 = null; 
			var szUser4 = null;
			
			switch(this.objClubRoundAssign_Acc.listData.length){
				case 4 : 	szUser4 = this.objClubRoundAssign_Acc.listData[3]["아이디"];
				case 3 : 	szUser3 = this.objClubRoundAssign_Acc.listData[2]["아이디"];
				case 2 : 	szUser2 = this.objClubRoundAssign_Acc.listData[1]["아이디"];
				case 1 : 	szUser1 = this.objClubRoundAssign_Acc.listData[0]["아이디"];
			}
			
			var submitData = {
					"동호회키": this.club_seq
					, "라운드키": this.round_seq
					, "저장팀키": this.team_seq
					, "조회팀키": this.team_seq
					, "용자1": szUser1
					, "용자2": szUser2
					, "용자3": szUser3
					, "용자4": szUser4
			}
			return submitData;
		}
		//변경된 데이터 확인
		, isCompare: function(){
			var compareData = this.objClubRoundAssign_Acc.compareData;
			var listData= this.objClubRoundAssign_Acc.listData;			
			if(compareData.length != listData.length) {
				return false;				
			}else {
				for(var i=0;i<compareData.length;++i){
					var bool = false;					
					for(var k=0;k<listData.length;++k){
						if(compareData[i]["아이디"]==listData[k]["아이디"]) bool = true;	
					}					
					if(!bool) return false;
				}
			}
			return true;
		}
	}